<?php
/*
* Template Name: Contact Page
*/
get_header(); 

// To Show Banner and Title
get_template_part( 'inc/title-bar' ); 
?>

		<!-- OPENING CONTENT -->
		<div id="content">
		
		        <?php 
					// Include Breadcrumb Bar
					get_template_part( 'inc/breadcrumb-sharebar' ); 
				?>
		
		         <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>				
		        
			        <div class="location-detail">
			        		<?php the_content(); ?>
			        </div>
				                        
			        <div class="map-container clearfix">
			                <div id="map_canvas"></div>							
							<?php
							if(is_page_template('template-contact.php'))
							{
								
								if( function_exists( 'ot_get_option' ))
								{
									$map_lati = ot_get_option( 'map_latitude' );
									$map_longi = ot_get_option( 'map_longitude' );
									$map_zoom = ot_get_option( 'map_zoom_level' );								
									?>
									<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
									<script type="text/javascript">
										// Google Map										
										function initialize() 
										{
											var geocoder  = new google.maps.Geocoder();
			  								var map;
											var latlng = new google.maps.LatLng(<?php echo $map_lati; ?>, <?php echo $map_longi; ?>);
											var infowindow = new google.maps.InfoWindow();
											var myOptions = { 
											  zoom: <?php echo $map_zoom; ?>,
											  mapTypeId: google.maps.MapTypeId.ROADMAP
											};
											
											map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
											
											geocoder.geocode( { 'location': latlng }, 
																function(results, status) {
																	      if (status == google.maps.GeocoderStatus.OK) 
																		  {
																	        map.setCenter(results[0].geometry.location);
																	        var marker = new google.maps.Marker({
																	            map: map, 
																	            position: results[0].geometry.location
																	        });
																			//alert(results[0].formatted_address);
																			//infowindow.setContent(results[0].formatted_address);
			          														//infowindow.open(map, marker);
																	      } 
																		  else 
																		  {
																	        alert("Geocode was not successful for the following reason: " + status);
																	      }
																});
											
										  }
										  										 
										  initialize();
									</script>     	 
									<?php
								}
							} 
							?>
			        </div>
							        
		        	<hr />
							        
		        <?php endwhile; ?>
		        <div class="contact-form-wrapper">
		        		<h3 class="title"><?php _e('Quick Query','locality'); ?></h3>
		               	<form id="contact-form" action="<?php echo site_url(); ?>/wp-admin/admin-ajax.php" method="post" >
							<p>
									<label for="name"><?php _e('Name*', 'locality') ?></label>
									<input type="text" class="input-bar required" id="name" name="name" value=""  />
							</p>
							<p>
									<label for="quick-email"><?php _e('Email*', 'locality') ?></label>
									<input class="input-bar email required" type="text" id="quick-email" name="email" value="" />
							</p>
							<p>
									<label for="message"><?php _e('Message*', 'locality') ?></label>
									<textarea name="message" id="message" cols="50" rows="10" class="message-box required"></textarea>
							</p>
							<p>
									<input type="hidden" name="action" value="send_message" />
									<input type="hidden" name="target" value="<?php if(function_exists('ot_get_option')){ echo ot_get_option('company_email'); }?>" />
									<input type="submit" name="contact-submit" id="contact-submit" value="<?php _e('Send Now','locality'); ?>" class="submit-btn" />
									<span id="message-sent"><?php _e('Thanks for Your Message!', 'locality'); ?></span>
									<img src="<?php echo get_template_directory_uri(); ?>/images/loader.gif" id="contact-loader" alt="Loader" />									
							</p>		                        
							<p>
									<span class="w-pet-border"></span>
							</p>
						</form>     		                
		        </div>
		</div><!-- CLOSING CONTENT -->
		
		<!-- SIDEBAR HOME -->
		<?php get_sidebar(); ?>

<?php get_footer(); ?>